@extends('admin.app')

@section('breadcrumb')
    <div class="bg-light lter b-b wrapper-md">
        <ol class="breadcrumb bg-light lter m-n no-padder">
            <li><a href="{{ admin_action('HomeController@index') }}">主页</a></li>
            <li>网站管理</li>
            <li class="active">财务管理</li>
        </ol>
    </div>
@endsection

@section('content')
    <div class="panel panel-default">
        <div class="panel-heading font-bold">
            交易列表
        </div>
        <div class="row wrapper">
            <form class="form-horizontal" method="get"
                  action="{{ admin_action('Web\FicoController@index') }}">
                <div class="form-group">
                    <label class="control-label col-sm-1">开始时间:</label>
                    <div class="col-sm-2">
                        <input type="text" class="form-control datetimepicker" name="start_at"
                               value="{{ $query['start_at'] }}" placeholder="请选择开始时间">
                    </div>

                    <label class="control-label col-sm-1">结束时间:</label>
                    <div class="col-sm-2">
                        <input type="text" class="form-control datetimepicker" name="end_at"
                               value="{{$query['end_at']}}" placeholder="请选择结束时间">
                    </div>
                    <div class="col-sm-6 text-right text-center-xs" style="padding-right: 30px;">
                        <a class="btn m-b-xs btn-sm btn-default btn-addon" href="/admin/web/fico/giftRecords" style="margin-bottom: 0px;">
                            红包查询
                        </a>
                        <a href="{{ admin_action('Web\FicoController@index',['download'=>'download','start_at'=>$query['start_at'],'end_at'=>$query['end_at'],'treade_cate_id'=>$query['treade_cate_id']]) }}" class="btn btn-sm btn-primary btn-addon">
                            <i class="fa fa-download"></i>excel导出查询结果
                        </a>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-sm-1">用户名:</label>
                    <div class="col-sm-2">
                        <input type="text" class="form-control" name="name"
                               value="{{$query['name']}}" placeholder="请输入用户名或真实姓名" >
                    </div>
                    <label class="control-label col-sm-1">交易类型:</label>
                    <div class="col-sm-2">
                        <select name="treade_cate_id" class="form-control select2">
                            <option value="">----请选择交易类型----</option>
                            <option value="4" {{$query['treade_cate_id']==4?'selected="selected"':''}}>充值</option>
                            <option value="5" {{$query['treade_cate_id']==5?'selected="selected"':''}}>提现</option>
                        </select>
                    </div>
                    <label class="control-label col-sm-1">交易状态:</label>
                    <div class="col-sm-2">
                        <select name="treade_status" class="form-control select2">
                            <option value="">----请选择交易状态----</option>
                            <option value="1" {{$query['treade_status']==1?'selected="selected"':''}}>成功</option>
                            <option value="0" {{$query['treade_status']=='0'?'selected="selected"':''}}>待完成</option>
                            <option value="-1" {{$query['treade_status']==-1?'selected="selected"':''}}>失败</option>
                        </select>
                    </div>
                    <div class="col-sm-3 text-right" style="padding-right: 30px;">
                            <span class="input-group-btn">
                              <button class="btn btn-sm btn-default" type="submit">查询</button>
                            </span>
                    </div>
                </div>
            </form>
        </div>
        <div class="table-responsive">
            <table class="table table-striped b-t b-light">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>用户名</th>
                    <th>真实姓名</th>
                    <th>银行渠道</th>
                    <th>交易金额</th>
                    <th>类型</th>
                    <th>用户手续费</th>
                    <th>平台手续费</th>
                    <th>实际到账金额</th>
                    <th>实际到账时间</th>
                    <th>状态</th>
                </tr>
                </thead>
                <tbody>
                @forelse ($list as $item)
                    <tr>
                        <td>
                            <a href="{{admin_action('Web\FicoController@checkTrade',[$item->id])}}">{{$item->sn}}</a>
                        </td>
                        <td>{{empty($item->username)?$item->phone_number:$item->username}}</td>
                        <td>{{$item->name}}</td>
                        <td>{{empty($bank_cate[$item->bank_code])?$item->bank_code:$bank_cate[$item->bank_code]->name}}</td>
                        <td>{{$item->money}}</td>
                        <td>{{$item->type==4?'充值':'提现'}}</td>
                        <td>{{$item->user_fee}}</td>
                        <td>{{$item->fee_money}}</td>
                        <td>{{$item->money-$item->user_fee}}</td>
                        <td>{{$item->pay_time}}</td>
                        <td>{{$item->status=='0'?'待完成':($item->status=='1'?'成功':'失败')}}</td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="3" class="text-center">没有找到交易记录</td>
                    </tr>
                @endforelse
                </tbody>
            </table>
        </div>
        <div class="panel-footer">
            <div class="row">
                <div class="col-sm-12 text-right text-center-xs">
                    {!! $links !!}
                </div>
            </div>
        </div>
    </div>
    <div class="panel panel-default">
        <div class="panel-heading font-bold">统计</div>
        <div class="panel-body">
            <div class="form-group">
                <label class="col-lg-2 control-label" style="margin-bottom: 0px;padding-top: 7px;padding-bottom: 7px;">当前平台累计给出手续费：</label>
                <div class="col-lg-10">
                    <p class="form-control-static">{{number_format($fee_money,2) }}元</p>
                </div>
            </div>
        </div>
    </div>
@endsection
@section('scripts')
    <script>
        /**
         * 格式化时间
         *
         * @param now
         * @returns {string}
         */
        function formatDate(now) {
            var year = now.getFullYear();
            var month = now.getMonth() + 1;
            var date = now.getDate();
            var hour = now.getHours();
            var minute = now.getMinutes();
            var second = now.getSeconds();
            return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
        }
        ;
    </script>
@endsection
